package JDBC;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class Zuoye05273 {
    public static void main(String[] args) {
        Connection con=null;
        PreparedStatement pr=null;
        Scanner input = new Scanner(System.in);
        String sql="insert into s_student values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
        System.out.println("请输入学生编号");
        int stuno = input.nextInt();
        System.out.println("请输入学生姓名");
        String name = input.next();
        System.out.println("请输入学生性别");
        String sex = input.next();
        System.out.println("请输入学生电话号码");
        String number = input.next();
        System.out.println("请输入学生qq");
        String qq = input.next();
        System.out.println("请输入学生微信");
        String wx = input.next();
        System.out.println("请输入学生年级号");
        int gid = input.nextInt();
        System.out.println("请输入学生入学时间");
        String date = input.next();
        System.out.println("请输入学生来自哪个城市");
        String city = input.next();
        System.out.println("请输入学生生日");
        String bithday = input.next();
        System.out.println("请输入学生家庭地址");
        String add = input.next();
        System.out.println("请输入学生密码");
        String pass = input.next();
        System.out.println("请输入学生身份证");
        String cardc = input.next();
        try {
            con = DBUtil.getConnection();
            pr = con.prepareStatement(sql);
            pr.setInt(1, stuno);
            pr.setString(2, name);
            pr.setString(3, sex);
            pr.setString(4, number);
            pr.setString(5, qq);
            pr.setString(6, wx);
            pr.setInt(7, gid);
            pr.setDate(8, Date.valueOf(date));
            pr.setString(9, city);
            pr.setDate(10, Date.valueOf(bithday));
            pr.setString(11, add);
            pr.setString(12, pass);
            pr.setString(13, cardc);
            int rs = pr.executeUpdate();
            System.out.println(rs==0?"添加失败":"添加成功");
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close(pr);
            DBUtil.close(con);
        }

    }
}
